package com.rx.mgt.dao;

import com.rx.mgt.dao.base.ManagementHibernateDaoBase;
import com.rx.mgt.domain.Group;
import com.rx.mgt.domain.UserInfoExt;
import com.rx.mgt.util.StringUtil;
import org.apache.commons.lang.StringUtils;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by zxj on 2017/4/26.
 */
@Repository
public class GroupDao extends ManagementHibernateDaoBase<Group,Long> {
    public List<Group> findGroupByDomain(String domain) {
        String hql = " from Group g where 1=1";
        if(StringUtils.isNotBlank(domain)){
            hql+=" and domain=:domain";
        }
        Query query = template.getSessionFactory().getCurrentSession().createQuery(hql);
        if(StringUtils.isNotBlank(domain)){
            query.setParameter("domain",domain);
        }
        return  (List<Group>) query.list();

    }


}
